package mylab.unitconversion;

public class TimeConverter {

	//nanoseconds to microseconds, milliseconds, seconds, minutes, hours, days, weeks, years
	public final static double NanosecondsMicrosecondsFactor	=	1000.0;				//1 microsecond = 1000 nanoseconds.
	public final static double NanosecondsMillisecondsFactor	=	1000000.0;			//1 millisecond = 1000000 nanoseconds.
	public final static double NanosecondsSecondsFactor			=	1000000000.0;		//1 second		= 1000000000 nanoseconds.
	public final static double NanosecondsMinutesFactor			=	60000000000.0;		//1 minute		= 60000000000 nanoseconds.
	public final static double NanosecondsHoursFactor			=	3600000000000.0;	//1 hour		= 3600000000000 nanoseconds.
	public final static double NanosecondsDaysFactor			=	86400000000000.0;	//1 day			= 86400000000000 nanoseconds.
	public final static double NanosecondsWeeksFactor			=	604800000000000.0;	//1 week		= 604800000000000 nanoseconds.
	public final static double NanosecondsYearsFactor			=	31557599740800000.0;//1 year		= 31557567081600000 nanoseconds.
	
	public static double nanosecondsToMicroseconds(double value){return value/NanosecondsMicrosecondsFactor;}
	public static double microsecondsToNanoseconds(double value){return value*NanosecondsMicrosecondsFactor;}
	
	public static double nanosecondsToMilliseconds(double value){return value/NanosecondsMillisecondsFactor;}
	public static double millisecondsToNanoseconds(double value){return value*NanosecondsMillisecondsFactor;}
	
	public static double nanosecondsToSeconds(double value){return value/NanosecondsSecondsFactor;}
	public static double secondsToNanoseconds(double value){return value*NanosecondsSecondsFactor;}
	
	public static double nanosecondsToMinutes(double value){return value/NanosecondsMinutesFactor;}
	public static double minutesToNanoseconds(double value){return value*NanosecondsMinutesFactor;}
	
	public static double nanosecondsToHours(double value){return value/NanosecondsHoursFactor;}
	public static double hoursToNanoseconds(double value){return value*NanosecondsHoursFactor;}
	
	public static double nanosecondsToDays(double value){return value/NanosecondsDaysFactor;}
	public static double daysToNanoseconds(double value){return value*NanosecondsDaysFactor;}
	
	public static double nanosecondsToWeeks(double value){return value/NanosecondsWeeksFactor;}
	public static double weeksToNanoseconds(double value){return value*NanosecondsWeeksFactor;}
	
	public static double nanosecondsToYears(double value){return value/NanosecondsYearsFactor;}
	public static double yearsToNanoseconds(double value){return value*NanosecondsYearsFactor;}
	
	
	//microseconds to milliseconds, seconds, minutes, hours, days, weeks, years
	public final static double MicrosecondsMillisecondsFactor	=	1000.0;				//1 millisecond	= 1000 microseconds.
	public final static double MicrosecondsSecondsFactor		=	1000000.0;			//1 second		= 1000000 microseconds.
	public final static double MicrosecondsMinutesFactor		=	60000000.0;			//1 minute		= 60000000 microseconds.
	public final static double MicrosecondsHoursFactor			=	3600000000.0;		//1 hour		= 3600000000 microseconds.
	public final static double MicrosecondsDaysFactor			=	86400000000.0;		//1 day			= 86400000000 microseconds.
	public final static double MicrosecondsWeeksFactor			=	604800000000.0;		//1 week		= 604800000000 microseconds.
	public final static double MicrosecondsYearsFactor			=	31557599740800.0;	//1 year		= 31557567081600 microseconds.

	public static double microsecondsToMilliseconds(double value){return value/MicrosecondsMillisecondsFactor;}
	public static double millisecondsToMicroseconds(double value){return value*MicrosecondsMillisecondsFactor;}
	
	public static double microsecondsToSeconds(double value){return value/MicrosecondsSecondsFactor;}
	public static double secondsToMicroseconds(double value){return value*MicrosecondsSecondsFactor;}
	
	public static double microsecondsToMinutes(double value){return value/MicrosecondsMinutesFactor;}
	public static double minutesToMicroseconds(double value){return value*MicrosecondsMinutesFactor;}
	
	public static double microsecondsToHours(double value){return value/MicrosecondsHoursFactor;}
	public static double hoursToMicroseconds(double value){return value*MicrosecondsHoursFactor;}
	
	public static double microsecondsToDays(double value){return value/MicrosecondsDaysFactor;}
	public static double daysToMicroseconds(double value){return value*MicrosecondsDaysFactor;}
	
	public static double microsecondsToWeeks(double value){return value/MicrosecondsWeeksFactor;}
	public static double weeksToMicroseconds(double value){return value*MicrosecondsWeeksFactor;}
	
	public static double microsecondsToYears(double value){return value/MicrosecondsYearsFactor;}
	public static double yearsToMicroseconds(double value){return value*MicrosecondsYearsFactor;}
	
	
	//milliseconds to seconds, minutes, hours, days, weeks, years
	public final static double MillisecondsSecondsFactor		=	1000.0;				//1 second		= 1000 milliseconds.
	public final static double MillisecondsMinutesFactor		=	60000.0;			//1 minute		= 60000 milliseconds.
	public final static double MillisecondsHoursFactor			=	3600000.0;			//1 hour		= 3600000 milliseconds.
	public final static double MillisecondsDaysFactor			=	86400000.0;			//1 day			= 86400000 milliseconds.
	public final static double MillisecondsWeeksFactor			=	604800000.0;		//1 week		= 604800000 milliseconds.
	public final static double MillisecondsYearsFactor			=	31557599740.8;		//1 year		= 31557567081.6 milliseconds.
	
	public static double millisecondsToSeconds(double value){return value/MillisecondsSecondsFactor;}
	public static double secondsToMilliseconds(double value){return value*MillisecondsSecondsFactor;}
	
	public static double millisecondsToMinutes(double value){return value/MillisecondsMinutesFactor;}
	public static double minutesToMilliseconds(double value){return value*MillisecondsMinutesFactor;}
	
	public static double millisecondsToHours(double value){return value/MillisecondsHoursFactor;}
	public static double hoursToMilliseconds(double value){return value*MillisecondsHoursFactor;}
	
	public static double millisecondsToDays(double value){return value/MillisecondsDaysFactor;}
	public static double daysToMilliseconds(double value){return value*MillisecondsDaysFactor;}
	
	public static double millisecondsToWeeks(double value){return value/MillisecondsWeeksFactor;}
	public static double weeksToMilliseconds(double value){return value*MillisecondsWeeksFactor;}
	
	public static double millisecondsToYears(double value){return value/MillisecondsYearsFactor;}
	public static double yearsToMilliseconds(double value){return value*MillisecondsYearsFactor;}
	
	
	//seconds to minutes, hours, days, weeks, years
	public final static double SecondsMinutesFactor				=	60.0;				//1 minute		= 60 seconds.
	public final static double SecondsHoursFactor				=	3600.0;				//1 hour		= 3600 seconds.
	public final static double SecondsDaysFactor				=	86400.0;			//1 day			= 86400.0 seconds.
	public final static double SecondsWeeksFactor				=	604800.0;			//1 week		= 604800.0 seconds.
	public final static double SecondsYearsFactor				=	31557599.7408;		//1 year		= 31557567.0816 seconds.
	
	public static double secondsToMinutes(double value){return value/SecondsMinutesFactor;}
	public static double minutesToSeconds(double value){return value*SecondsMinutesFactor;}
	
	public static double secondsToHours(double value){return value/SecondsHoursFactor;}
	public static double hoursToSeconds(double value){return value*SecondsHoursFactor;}
	
	public static double secondsToDays(double value){return value/SecondsDaysFactor;}
	public static double daysToSeconds(double value){return value*SecondsDaysFactor;}
	
	public static double secondsToWeeks(double value){return value/SecondsWeeksFactor;}
	public static double weeksToSeconds(double value){return value*SecondsWeeksFactor;}
	
	public static double secondsToYears(double value){return value/SecondsYearsFactor;}
	public static double yearsToSeconds(double value){return value*SecondsYearsFactor;}
	
	
	//minutes to hours, days, weeks, years
	public final static double MinutesHoursFactor				=	60.0;				//1 hour		= 60 minutes;
	public final static double MinutesDaysFactor				=	1440.0;				//1 day			= 1440 minutes;
	public final static double MinutesWeeksFactor				=	10080.0;			//1 week		= 10080 minutes;
	public final static double MinutesYearsFactor				=	525959.99568;		//1 year		= 525959.99568 minutes;
	
	public static double minutesToHours(double value){return value/MinutesHoursFactor;}
	public static double hoursToMinutes(double value){return value*MinutesHoursFactor;}
	
	public static double minutesToDays(double value){return value/MinutesDaysFactor;}
	public static double daysToMinutes(double value){return value*MinutesDaysFactor;}
	
	public static double minutesToWeeks(double value){return value/MinutesWeeksFactor;}
	public static double weeksToMinutes(double value){return value*MinutesWeeksFactor;}
	
	public static double minutesToYears(double value){return value/MinutesYearsFactor;}
	public static double yearsToMinutes(double value){return value*MinutesYearsFactor;}
	
	
	//hours to days, weeks, years
	public final static double HoursDaysFactor					=	24.0;				//1 day			= 24 hours;
	public final static double HoursWeeksFactor					=	168.0;				//1 week		= 168 hours;
	public final static double HoursYearsFactor					=	8765.99993;			//1 year		= 8765.9999.3 hours;
	
	public static double hoursToDays(double value){return value/HoursDaysFactor;}
	public static double daysToHours(double value){return value*HoursDaysFactor;}
	
	public static double hoursToWeeks(double value){return value/HoursWeeksFactor;}
	public static double weeksToHours(double value){return value*HoursWeeksFactor;}
	
	public static double hoursToYears(double value){return value/HoursYearsFactor;}
	public static double yearsToHours(double value){return value*HoursYearsFactor;}
	
	//days to weeks, years
	public final static double DaysWeeksFactor					=	7.0;				//1 week		= 7 days;
	public final static double DaysYearsFactor					=	365.25;				//1 year		= 365.25 days;
	
	public static double daysToWeeks(double value){return value/DaysWeeksFactor;}
	public static double weeksToDays(double value){return value*DaysWeeksFactor;}
	
	public static double daysToYears(double value){return value/DaysYearsFactor;}
	public static double yearsToDays(double value){return value*DaysYearsFactor;}
	
	//weeks to years
	public final static double WeeksYearsFactor					=	52.178571;			//1 year		= 52.178571 weeks;
	
	public static double weeksToYears(double value){return value/WeeksYearsFactor;}
	public static double yearsToWeeks(double value){return value*WeeksYearsFactor;}
	
}
